package com.nagornyi.uc.action;

import com.google.appengine.labs.repackaged.org.json.JSONException;
import com.nagornyi.uc.Role;
import com.nagornyi.uc.dao.DAOFacade;
import com.nagornyi.uc.dao.IUserDAO;
import com.nagornyi.uc.entity.User;
import com.nagornyi.uc.transport.ActionRequest;
import com.nagornyi.uc.transport.ActionResponse;

/**
 * @author Nagorny
 *         Date: 17.05.14
 */
public class MakeAdminAction implements Action {

    @Override
    public void perform(ActionRequest req, ActionResponse resp) throws JSONException {
        IUserDAO dao = DAOFacade.getDAO(User.class);
        User me = dao.getUserByEmail("hop.oleg@gmail.com");
        me.setRole(Role.ADMIN);
        DAOFacade.save(me);
//        req.getSession().setAttribute("user", me);
    }
}
